#include<graphics.h>
#include<conio.h>
#include<stdio.h>
#define PI 3.14159

int main()
{
	initgraph(800, 600);//打开一个窗口
	setbkcolor(RGB(128, 128, 128));//设置背景颜色为灰色
	cleardevice();//以背景颜色清空画布

	int centerX = 300;//圆心X坐标
	int centerY = 300;//圆心Y坐标
	int radius = 200;//圆心半径
	int i;
	float offset;
	
	while(1)//重复进行
	{
		for(centerX = 100;centerX < 800;centerX += 200)
		{
			for(centerY = 100;centerY < 600;centerY += 200)
			{
				float totaloffset = 0;//不同半径之间的角度的偏移量
				float h = rand() %180;
				COLORREF color1 = HSVtoRGB(h, 0.9, 0.8);
				COLORREF color2 = HSVtoRGB(h + 180, 0.9, 0.8);
				for(radius = 100; radius > 0;radius -= 20)
				{
					
					int left = centerX - radius;//圆外切矩形左上角x坐标
					int top = centerY - radius;//圆外切矩形左上角y坐标
					int right = centerX + radius;//圆外切矩形右下角x坐标
					int bottom = centerY + radius;//圆外切矩形右下角y坐标

					for(i = 0;i < 20;i++)
					{
						offset = i * PI / 10 + totaloffset;
						setfillcolor(color1);//设置填充色为青色
						solidpie(left, top, right, bottom, offset, 2 * PI / 60 + offset);//画填充扇形
						setfillcolor(RGB(255, 255, 255));//设置填充颜色为红色
						solidpie(left, top, right, bottom, 2 * PI / 60 + offset, 3 * PI / 60 + offset);//画填充扇形
						setfillcolor(color2);//设置填充颜色为红色
						solidpie(left, top, right, bottom, 3 * PI / 60 + offset, 5 * PI / 60 + offset);//画填充扇形
						setfillcolor(RGB(0, 0, 0));//设置填充颜色为黑色
						solidpie(left, top, right, bottom, 5 * PI / 60 + offset, 6 * PI / 60 + offset);//画填充扇形
					}
					totaloffset = totaloffset + PI / 20;
				}
			}
		}
		_getch();//暂停，等待键入
	}
	return 0;
}
